<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>
			OA办公管理系统桌面
		</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="format-detection" content="telephone=no">
		<link rel="stylesheet" href="./css/x-admin.css" media="all">
		<link rel="stylesheet" href="./lib/bootstrap/css/bootstrap.css" media="all">
		<link rel="stylesheet" href="./layui/css/layui.css">
		<script type="text/javascript" src="js/global.js"></script>
		<script src="./layui/layui.js"></script>
		<script type="text/javascript" src="js/jquery.min.js"></script>
	</head>

	<body>
		<style type="text/css">
			legend {
				display: block;
				width: 100px;
				border-bottom: 0px;
				font-family: "Microsoft YaHei", "Helvetica Neue";
			}
			
			legend a {
				color: #666;
			}
			
			legend a:hover {
				text-decoration: none;
			}
			
			.layui-table {
				font-family: "Microsoft YaHei", "Helvetica Neue";
			}
		</style>
		<div class="x-body">
			<blockquote class="layui-elem-quote">
				欢迎:&nbsp;&nbsp;<span class="f-14" style="color: red;" id="spName"></span> &nbsp;&nbsp;
				<span class="f-14" id="data"></span>
			</blockquote>
		</div>
		<div id="insaker" class="layui-btn-container" style="text-align: center;">
			<!--<button class="layui-btn" id="inAsker" lay-submit lay-filter="formDemo">签到</button>-->
		</div>

		<script>
			layui.use('form', function() {
				var $ = layui.jquery; //引入jquery
				//解决跨域
				$.ajaxPrefilter(function(options, originalOptions, jqXHR) {
					options.xhrFields = {
						withCredentials: true
					}
				})
				$(function() {
					//					签到
					$.ajax({
						type: "post",
						url: globalData.server + "./asker/askerYesNo?loginName=" + globalData.getUserName(), //据登录名查询是否该签到
						dataType: "json",
						success: function(data) {
							$("#insaker").html("");
							if(data.count > 0) { //签到按钮显示，
								$.ajax({
									type: "post",
									url: globalData.server + "./asker/askerYesNoAsker?askerName=" + globalData.getUserName(), //据登录名查询是否该签到
									dataType: "json",
									success: function(data1) { //再去判断是否已经签到
										if(data1.count == 0) { //=0未签到 追加
											$("#insaker").append('<button class="layui-btn" id="inAsker" onclick="inAskers()"  >签到</button>');
										}
									}

								});
							}
						}
					});
					//根据登录名去查询未读的消息
					$.ajax({
						type: "post",
						url: globalData.server + "./message/noRead?askerName=" + globalData.getUserName(), //据登录名查询是否该签到
						dataType: "json",
						success: function(data) {
							console.log(data);
							if(data.count > 0) { //消息未读
								layer.open({
									type: 2,
									title: false,
									closeBtn: 1, //不显示关闭按钮
									shade: [0],
									area: ['150px', '75px'],
									offset: 'rb', //右下角弹出
									//								   time: 2000, //2秒后自动关闭
									anim: 2,
									content: ['message-no-read.html', 'no'], //iframe的url，no代表不显示滚动条 右下角页面
								});
							}
						}
					});

				})

				$("#spName").html(globalData.getUserName());
				strTime = new Date();
				$("#data").html(strTime.toLocaleString());
				//安全退出
			});
			//监听提交签到
			function inAskers() {
				var d = {
					'askerName': globalData.getUserName(),
					'exOne': globalData.getUid(),
				}; //表单中的数据，定义一个对象来接收
				var url = globalData.server + './asker/add';
				$.post(url, d, function(data) {
					console.log(data);
					if(data.count > 0) {
						layer.msg(data.msg, {
							icon: 6
						});
						setTimeout(function() {
							window.parent.location.reload();
							//							window.location.reload(); //刷新页面
						}, 2000);
					}
				}, "json");
			}
			//iframe窗

			//layer.open({
			// type: 2,
			// title: false,
			// closeBtn: 0, //不显示关闭按钮
			// shade: [0],
			// area: ['340px', '215px'],
			// offset: 'rb', //右下角弹出
			// time: 2000, //2秒后自动关闭
			// anim: 2,
			// content: ['student.html', 'no'], //iframe的url，no代表不显示滚动条 右下角页面
			// end: function () { //此处用于演示
			// layer.open({
			// type: 2,
			// title: '很多时候，我们想最大化看，比如像这个页面。',
			// shadeClose: true,
			// shade: false,
			// maxmin: true, //开启最大化最小化按钮
			// area: ['893px', '600px'],
			// content: 'text.html' //最大化页面
			// });
			// }
			//});
		</script>
	</body>

</html>